package com.gongyou.forum.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gongyou.common.pojo.Yuepai;
import com.gongyou.forum.mapper.YuePaiMapper;
import com.gongyou.forum.service.YuePaiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author LiQuanPing
 * @Date 2021-03-21 16:55
 * @Version 1.8
 * @creed: ♂♂Talk is cheap,show me the code♀♀
 */
@Service
public class YuePaiServiceImpl implements YuePaiService {

    @Autowired
    private YuePaiMapper yuePaiMapper;

    //读取所有约拍信息
    @Override
    public Page getAllYuePaiInfo(Map map,String currentPage) {
        String text1 = (String) map.get("text1");
        String text2 = (String) map.get("text1");
        String text3 = (String) map.get("text1");
    //    String currentPage = (String) map.get("page");
        long parseLong = Long.parseLong(currentPage);
        Page page = new Page(0, parseLong * 10);
        Page page1 = yuePaiMapper.selectPage(page, new QueryWrapper<Yuepai>().eq(text1 != "", "identity", text1).eq(text2 != "", "p_gender", text2).eq(text3 != "", "faceplace", text3).eq("is_del",0).orderByDesc("pub_date"));
        List<Yuepai> records = page1.getRecords();
        if (records.size() > 0 || records != null) {
            for (Yuepai record : records) {
                List list = JSON.parseObject(record.getUrls(), List.class);
                record.setUrlsList(list);
            }
        }
        page1.setRecords(records);
        return page1;
    }
}
